//Maths header
//Maths library functions

#ifndef MATHS_H
#define MAtHS_H

namespace Maths
{
	// Max
	template <typename T>
	T Max(T a, T b)
	{
		if (a > b) return a;
		return b;
	}

	// Min
	template <typename T>
	T Min(T a, T b)
	{
		if (a < b) return a;
		return b;
	}

	// Length
	template <typename T>
	float Length2D(T a, T b)
	{
		T vector = a - b;
		float length = sprtf(vector.x * vector.x + vector.y * vector.y);
		return length;
	}

	template <typename T>
	float Length3D(T a, T b)
	{
		T vector = a - b;
		float length = sprtf(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z);
		return length;
	}

	// Clamp
	template <typename T>
	T Clamp(T n, T min, T max)
	{
		if (n > max) return max;
		if (n < min) return min;
		return n;

		// ALTERNATIVE:
		//n = Min(n, max);
		//n = Max(n, min);
		//return n;
	}

	// Saturate
	template <typename T>
	T Saturate(T n)
	{
		return Clamp<T>(n, 0, 1);
	}

	// Lerp
	template <typename T>
	T Lerp(T min, T max, float alpha)
	{
		return min + (max - min) * alpha;

	}

}


#endif //MATHS_H